"""
Management utility to create superusers.
"""
from django.core.management import BaseCommand
from django.db import DEFAULT_DB_ALIAS

from person.models.person import Person


class Command(BaseCommand):

    def __init__(self):
        super().__init__()
        self.UserModel = Person

    def handle(self, *args, **options):
        username = options.get('username')
        person_data = {}
        person_data['username'] = username
        person_data['password'] = '123456'
        person_data['realName'] = '超级管理员'
        person_data['email'] = None
        person_data['phone'] = None
        self.UserModel._default_manager.db_manager('default').create_super_person(**person_data)

    def add_arguments(self, parser):
        parser.add_argument("--username", help = "用户名")
